import { Component, Prop } from 'vue-property-decorator';

import { isFunction } from '../../vendors/handie';

import FieldHeadlessWidget from './Field';

@Component
export default class StringFieldHeadlessWidget extends FieldHeadlessWidget<string> {
  @Prop({ type: String, default: '' })
  protected readonly value!: string;

  protected formatValue(value: string = this.value): string {
    return isFunction(this.field.formatter) ? this.field.formatter!(value) : value;
  }
}
